using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Collections;

using System.Windows.Forms;
using System.Drawing;
using Camalon.Drawing;
using Camalon.Drawing.Shapes;

namespace Camalon.Drawing.Design
{
	/// <summary>
	/// Summary description for RectangleDesigner.
	/// </summary>
	public class RectangleShapeDesigner:ShapeDesigner
	{
		public RectangleShapeDesigner()
		{
			//
			// TODO: Add constructor logic here
			//
		}


		public RectangleShape RectangleShape
		{
			get{ return (RectangleShape)this.Component;}
		}

		PropertyDescriptor	_propTopLeft		= TypeDescriptor.GetProperties(typeof( RectangleShape ))["TopLeft"];
		PropertyDescriptor	_propTopRight		= TypeDescriptor.GetProperties(typeof( RectangleShape ))["TopRight"];
		PropertyDescriptor	_propBottomLeft		= TypeDescriptor.GetProperties(typeof( RectangleShape ))["BottomLeft"];
		PropertyDescriptor	_propBottomRight	= TypeDescriptor.GetProperties(typeof( RectangleShape ))["BottomRight"];
		
		Corner _oldTopLeft		= Corner.Empty;
		Corner _oldTopRight		= Corner.Empty;
		Corner _oldBottomLeft	= Corner.Empty;
		Corner _oldBottomRight	= Corner.Empty;

		public override void BeginEditControlPoints()
		{
			_oldTopLeft		= this.RectangleShape.TopLeft;
			_oldTopRight	= this.RectangleShape.TopRight;
			_oldBottomLeft	= this.RectangleShape.BottomLeft;
			_oldBottomRight	= this.RectangleShape.BottomRight;

			base.BeginEditControlPoints ();
		}

		public override void EndEditControlPoints()
		{
			Corner newTopLeft		= this.RectangleShape.TopLeft;
			Corner newTopRight		= this.RectangleShape.TopRight;
			Corner newBottomLeft	= this.RectangleShape.BottomLeft;
			Corner newBottomRight	= this.RectangleShape.BottomRight;

			this.RectangleShape.TopLeft		= _oldTopLeft;
			this.RectangleShape.TopRight	= _oldTopRight;
			this.RectangleShape.BottomLeft	= _oldBottomLeft;
			this.RectangleShape.BottomRight	= _oldBottomRight;

			_propTopLeft.SetValue( this.RectangleShape, newTopLeft);
			_propTopRight.SetValue( this.RectangleShape, newTopRight);
			_propBottomLeft.SetValue( this.RectangleShape, newBottomLeft);
			_propBottomRight.SetValue( this.RectangleShape, newBottomRight);

			
			base.EndEditControlPoints ();
		}


		

	}
}
